package com.iclient.dao.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iclient.dao.mapper.MCookieMapper;
import com.iclient.dao.model.MCookie;
import com.iclient.dao.service.MCookieService;

@Service
public class MCookieServiceImpl implements MCookieService{

	@Autowired
	private MCookieMapper mCookieMapper;
	
	@Override
	public void addMCookie(String content, String type){
		mCookieMapper.deleteByType(type);
		MCookie mCookie = new MCookie();
		mCookie.setContent(content);
		mCookie.setCreateTime(new Date());
		mCookie.setValid(false);
		mCookie.setExpired(false);
		mCookieMapper.insert(mCookie);
	}
	
	@Override
	public void updateMCookie(MCookie mCookie){
		mCookieMapper.updateByPrimaryKey(mCookie);
	}
	
	@Override
	public MCookie findByType(String type){
		return mCookieMapper.findByType(type);
	}
}
